package itheima01;

import java.sql.*;

/**
 * @author xxx
 * @date 2021/1/3 15:35
 * @description
 */
public class Test {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //D:\java349\day18\lib\mysql-connector-java-5.1.37-bin.jar!\com\mysql\jdbc\Driver.class
         Class.forName("com.mysql.jdbc.Driver");
        String url="jdbc:mysql://localhost:3306/day18";
        String user="root";
        String password="root";
        Connection connection= DriverManager.getConnection(url,user,password);

        Statement statement =connection.createStatement();
        String  sql="select * from scores";

        ResultSet resultSet=statement.executeQuery(sql);

        while (resultSet.next()){
            Integer a=resultSet.getInt(1);
            Integer b=resultSet.getInt(2);
            String  c=resultSet.getString(3);
            System.out.println("编号: "+a+", 姓名: "+b+", 成绩: "+c);
        }
        connection.close();
        statement.close();
        resultSet.close();

    }
}
